package libutil;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.File;
/**
 *
 * @author axl
 */
public class fileutil {

    protected File myfile;
    protected String system;
    public fileutil(){
    	system = System.getProperty("os.name");
    	//System.out.println(system);
    }
    public String makedirectory(String name){
        try{
            myfile = new File(name);
            if(!myfile.exists()){
                myfile.mkdir();
                return myfile.getAbsolutePath();
            }else{
                return myfile.getAbsolutePath();
            }
            
        }catch (Exception makedirex){
            makedirex.printStackTrace();
            return "errormakedir";
        }
        
        
    }
    public String Getdirectoryname(){
        try
        {
            return myfile.getAbsolutePath();
        }catch (Exception ioexcept)
        {
            ioexcept.printStackTrace();
            return "errordir";
        }
    }
    public String makepathforfile(String file){
    	if(system.equals("Linux")){
    		return this.myfile.getAbsolutePath()+"/"+file;
    	}else{
    		return this.myfile.getAbsolutePath()+"\\"+file;
    	}
    }
    public static String makepathforfile(String file, String path){
    	if(System.getProperty("os.name").equals("Linux")){
    		return path+"/"+file;
    	}else{
    		return path+"\\"+file;
    	}
    }
    public static String getcurrentdirectory(){
    	File f = new File(".");
    	return f.getAbsolutePath();
    }
}
